<template lang="html">
  <el-upload
    class="upload-demo"
    multiple
    list-type="picture-card"
    action="https://api.zgwyzxw.cn/files"
    :headers="headers"
    :data="uploadData"
    accept="image/png, image/jpeg, image/gif, image/jpg"
    :on-success="handleSuccess"
    :on-remove="handleRemove"
    ref="upload"
    >
    <i class="el-icon-plus"></i>
  </el-upload>
</template>

<script>
import {loadToken} from 'common/js/cache'
export default {
  data() {
    return {
      uploadData: {
        prefix: 'article/sfsdf/'
      }
    }
  },
  computed: {
    headers() {
      return {
        'Authorization': `Bearer ${loadToken()}\n`
      }
    }
  },
  methods: {
    handleSuccess(file) {
      this.$emit('upload', file)
    },
    handleRemove(file) {
      this.$emit('del', file)
    }
  }
}
</script>

<style lang="css">
</style>
